<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:form>



            <p:panel  >
                <f:facet name="header" >
                    <h:outputLabel value="Update Bulk Categery" ></h:outputLabel>
                </f:facet>


                <p:panel header="Items">
                    <p:panel header="All Pharmacy Items" >

                        <h:panelGrid columns="5" >
                            <h:outputLabel value="Category" />
                            <p:autoComplete  value="#{pharmacyUpdateBulkController.category}" 
                                             forceSelection="true"
                                             completeMethod="#{pharmaceuticalItemCategoryController.completeCategory}" 
                                             var="vt" itemLabel="#{vt.name}" itemValue="#{vt}" >
                            </p:autoComplete>   
                            <p:commandButton ajax="false" value="Process" 
                                            actionListener="#{pharmacyUpdateBulkController.fillPharmacyItems}" ></p:commandButton>
                        </h:panelGrid>

                        <h:panelGroup id="gpBillPreview"  styleClass="noBorder summeryBorder" style="min-width: 100%!important;">

                            <p:dataTable id="tbl" rowIndexVar="ii" 
                                         value="#{pharmacyUpdateBulkController.amps}" var="i"
                                         rows="50"
                                         paginator="true"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="20, 50, 100">


                                <p:column width="40px;" headerText="No" sortBy="#{ii}">
                                    <h:outputLabel value="#{ii+1}" />
                                </p:column>

                                <p:column headerText="Code" width="50px;" sortBy="#{i.code}" filterBy="#{i.code}"
                                          filterMatchMode="startsWith">
                                    <f:facet name="header">
                                        <h:outputLabel value="Code"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.code}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Item" width="300px;" sortBy="#{i.name}" filterBy="#{i.name}"
                                          filterMatchMode="contains">
                                    <f:facet name="header">
                                        <h:outputLabel value="Item"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.name}" ></h:outputLabel>
                                </p:column>


                                <p:column headerText="Category" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Category"/>                                     
                                    </f:facet>
                                    <h:outputLabel value="#{i.category.name}"  >

                                    </h:outputLabel>
                                </p:column>



                            </p:dataTable>
                        </h:panelGroup>
                    </p:panel>
                </p:panel>
                <p:panel header="Update Item Category" >
                    <p:panelGrid columns="3">
                        <h:outputLabel value="Update Category #{pharmacyUpdateBulkController.category} to Category" />
                        <p:autoComplete  value="#{pharmacyUpdateBulkController.updateCategory}" 
                                         forceSelection="true"
                                         completeMethod="#{pharmaceuticalItemCategoryController.completeCategory}" 
                                         var="vt" itemLabel="#{vt.name}" itemValue="#{vt}" >
                        </p:autoComplete>   
                        <p:commandButton ajax="false" value="Update" onclick="if (!confirm('Are you sure you want to Update Categories ?'))
                                    return false;" actionListener="#{pharmacyUpdateBulkController.updatePharmacyItemCategory()}" ></p:commandButton>
                    </p:panelGrid>
                </p:panel>

            </p:panel>




        </h:form>



    </ui:define>

</ui:composition>
